import React, { useRef } from 'react';
import { Row, Col } from 'antd';
import Flow from '../../../Strategy/Strategy/flow/flow';
import CodeLabel from '../../../../components/CodeLabel';
import './index.less';

export default function PolicyFlow(props) {
  const _flow = useRef(); //flow对象
  function handleRef(ref) {
    _flow.current = ref;
    props.onRef && props.onRef(_flow.current);
  }
  const value = { nodes: props.record.nodes, edges: props.record.edges };
  return (
    <div className='policy-flow'>
      <Row type='flex' gutter={20} style={{ marginBottom: '20px' }}>
        <Col>策略模式： {props.record.strategy_mode_name}</Col>
        <Col>
          执行结果：
          <CodeLabel code='hit_handle' value={props.record.hit_result} />
        </Col>
      </Row>
      <Flow
        {...props}
        value={value}
        onRef={ref => handleRef(ref)}
        disabled={true}
        graphicMode={'result'}
        isResult={true}
        operator={[]}
      />
    </div>
  );
}
